/* eslint-disable react/no-multi-comp */
import React, { Component } from 'react';
import { YunxiaoIcon } from '@alife/devops-ui';

export class PipelineIconFont extends Component {
  shouldComponentUpdate(nextProps) {
    return nextProps.type !== this.props.type;
  }

  getType = (type) => {
    if (type === 'aliyunGit' || type === 'giteeGit') {
      return type.replace('Git', '');
    }
    if (type === 'force') {
      return 'git';
    }
    if (type === 'gitSample' || type === 'flow') {
      return 'flow-';
    }
    if (type === 'jenkins') {
      return 'jenkins';
    }
    if (type === 'githubOAuth') {
      return 'github';
    }
    if (type === 'customGitlab') {
      return 'gitlab';
    }
    return type;
  };

  render() {
    const { type, ...restProps } = this.props;
    return <YunxiaoIcon type={this.getType(type)} source="pl" {...restProps} />;
  }
}

/**
 * at 流水线图标
 */
export default PipelineIconFont;
